package com.gitee.wsl.common.chart.sample

import android.graphics.Canvas
import android.graphics.Paint
import androidx.core.graphics.withSave
import com.gitee.wsl.common.chart.ChartEnum
import com.gitee.wsl.common.chart.render.background.axis.AxisTitle
import com.gitee.wsl.common.chart.render.background.axis.line.CategoryLineAxis
import com.gitee.wsl.common.chart.render.background.axis.line.DataLineAxis
import com.gitee.wsl.common.chart.render.background.grid.PlotGrid
import com.gitee.wsl.transform.format.Format
import com.gitee.wsl.math.Math
import com.gitee.wsl.android.ext.math.dp
import com.gitee.wsl.android.ui.base.innerRect
import com.gitee.wsl.common.ui.draw.type.GridDirection
import com.gitee.wsl.common.ui.draw.type.HorizontalAlign
import com.gitee.wsl.common.ui.draw.type.PanMode
import com.gitee.wsl.common.ui.draw.type.VerticalAlign
import com.gitee.wsl.jvm.math.add
import com.gitee.wsl.jvm.math.div
import com.gitee.wsl.jvm.math.mul
import com.gitee.wsl.jvm.math.sub
import timber.log.Timber


abstract class AbstractAxesChart(touchCheckAble: com.gitee.wsl.common.ui.api.TouchCheckAble? = null) : XChart(touchCheckAble) {

    //val axisMap = mutableMapOf<ChartEnum.AxisLocation, BaseAxis>()

    //数据轴
    var dataAxis: DataLineAxis = DataLineAxis()

    //标签轴
    var categoryAxis: CategoryLineAxis = CategoryLineAxis()

    //坐标从第一个刻度而不是轴开始
    var xCoordFirstTickmarksBegin = false

    //轴标题类
    var axisTitle: AxisTitle? = null


    // 确定是竖向柱形图(默认)还是横向
    var chartDirection = ChartEnum.ChartDirection.VERTICAL

    //数据轴显示在左边还是右边
    var dataAxisLocation by dataAxis::axisLocation

    var categoryAxisLocation by categoryAxis::axisLocation

    //轴刻度的位置信息
    val lstDataTick  by dataAxis::lstLabels

    val lstCateTick  by categoryAxis::lstLabels

    //格式化柱形顶上或线交叉点的标签
    var itemLabelFormatter: Format<Double>? = null

    // 确定是竖向柱形图(默认)还是横向
     var gridDirection = GridDirection.VERTICAL

    //Pan模式下移动距离
    val moveX by currentViewport::left
    val moveY by currentViewport::top

    //是否将轴封闭
    var isAxesClosed = false

    // 对于轴标签滑动时的显示处理并不是很好，不过已经没精力重构了。
    // 目前可用下面的方式来限定:
    //     可通过指定下面两个参数值来限定x/y轴标签可移出的范围
    //     但注意这两个参数是同时限制上下或左右。
    //var myMargin = -10.0f
    //var mxMargin = -25f // 25.0f; //散点和气泡要注意下

    var myMargin = 0f
    var mxMargin = 0f // 25.0f; //散点和气泡要注意下

   // val clipExt: ClipExt = ClipExt()

    init {
        //初始化图例
        plotLegend.isVisible = true
        plotLegend.legendType = ChartEnum.LegendType.ROW
        plotLegend.horizontalAlign = HorizontalAlign.LEFT
        plotLegend.verticalAlign = VerticalAlign.TOP
        plotLegend.isShowBox = false

        axisDefaultSetting()
    }

    private fun axisDefaultSetting() {
        dataAxisDefaultSetting(dataAxis)
        categoryAxisDefaultSetting(categoryAxis)
    }

    override fun setChartRange(startX: Float, startY: Float,width: Float, height: Float) {
        super.setChartRange(startX, startY, width, height)

        if (categoryAxis.isAxisVisible) {
            calcBodyRectWithAxis(categoryAxisLocation)
        }
        if (dataAxis.isAxisVisible){
            calcBodyRectWithAxis(dataAxisLocation)
        }
    }

    private fun calcBodyRectWithAxis(axisLocation: ChartEnum.AxisLocation){
        Timber.d("calcBodyRectWithAxis axisLocation:$axisLocation")
        val axisWidth = 20f.dp
        when(axisLocation){
            ChartEnum.AxisLocation.LEFT->{
                chartCommutator.insetContentRect(deltaLeft = axisWidth)
            }
            ChartEnum.AxisLocation.BOTTOM->{
                chartCommutator.insetContentRect(deltaBottom = axisWidth)
            }
            ChartEnum.AxisLocation.RIGHT->{
                chartCommutator.insetContentRect(deltaRight = axisWidth)
            }
            ChartEnum.AxisLocation.TOP->{
                chartCommutator.insetContentRect(deltaTop = axisWidth)
            }
            else -> {}
        }
    }

    protected open fun categoryAxisDefaultSetting(categoryAxis: CategoryLineAxis) {
        if (!categoryAxis.isAxisVisible) return
        categoryAxisLocation = when (chartDirection) {
            ChartEnum.ChartDirection.HORIZONTAL -> {
                ChartEnum.AxisLocation.LEFT
            }

            ChartEnum.ChartDirection.VERTICAL -> {
                ChartEnum.AxisLocation.BOTTOM
            }
        }
        if (ChartEnum.AxisLocation.LEFT == dataAxisLocation) {
            categoryAxis.tickMarksAlign = Paint.Align.CENTER
        }
        categoryAxis.axisPaint.strokeWidth = 2f
        categoryAxis.tickMarkPaint.strokeWidth = 2f
    }

    protected open fun dataAxisDefaultSetting(dataAxis: DataLineAxis) {
        if (!dataAxis.isAxisVisible) return
        dataAxisLocation = when (chartDirection) {
            ChartEnum.ChartDirection.HORIZONTAL -> ChartEnum.AxisLocation.BOTTOM
            ChartEnum.ChartDirection.VERTICAL -> ChartEnum.AxisLocation.LEFT
        }
        if (ChartEnum.AxisLocation.LEFT == dataAxisLocation) {
            dataAxis.tickMarksAlign = Paint.Align.LEFT
        } else {
            dataAxis.tickMarksAlign = Paint.Align.RIGHT
            if (dataAxis.isShowAxisLabels)
                dataAxis.tickLabelPaint.textAlign = Paint.Align.LEFT
        }
        if (dataAxis.isAxisLineVisible) dataAxis.axisPaint.strokeWidth = 2f
        if (dataAxis.isTickMarksVisible) dataAxis.tickMarkPaint.strokeWidth = 2f
    }


    ////////////////////////////
    /*protected  fun initMoveXY() {
        moveY = 0.0f
        moveX = moveY
        when (plotPanMode) {
            DrawEnum.PanMode.HORIZONTAL -> moveX = translateXY[0]
            DrawEnum.PanMode.VERTICAL -> moveY = translateXY[1]
            else -> {
                moveX = translateXY[0]
                moveY = translateXY[1]
            }
        }
    }*/


    protected  fun getPlotScreenWidth(): Float {
        return bodyViewport.width
    }

    protected  fun getPlotScreenHeight(): Float {
        return bodyViewport.height
    }

    /**
     * 轴所占的屏幕宽度
     * @return  屏幕宽度
     */
    protected  fun getAxisScreenWidth(): Float {
        return bodyViewport.width
    }

    /**
     * 轴所占的屏幕高度
     * @return 屏幕高度
     */
    protected  fun getAxisScreenHeight(): Float {
        return bodyViewport.height
    }

    open fun setCategories(mLabels: List<String>) {
        categoryAxis.setDataBuilding(mLabels)
    }

    protected open fun getCategoryAxisLabelTickCount(categoryAxis: CategoryLineAxis): Int {
        val tickCount: Int = categoryAxis.dataSet.size
        val labeltickCount  = if (0 == tickCount) {
            Timber.d("分类轴数据源为0!")
             0
        } else if (1 == tickCount) { // label仅一个时右移
            tickCount
        } else {
            if (xCoordFirstTickmarksBegin) {
                tickCount + 1
            } else {
                tickCount - 1
            }
        }
        return labeltickCount
    }


    //////////////////////////////////////////////////////////
    //竖轴

    /**
     * 返回指定数据在图中的竖向坐标位置
     *
     * @param bv
     * 数据
     * @return 坐标位置
     */
    protected open fun getVPValPosition(bv: Float,dataAxis:DataLineAxis): Float {
        val vaxlen =  Math.sub(bv, dataAxis.axisMin)
        val valuePostion: Float =  Math.mul(getPlotScreenHeight(),  Math.div(vaxlen, dataAxis.axisRange))
        return  Math.sub(bodyViewport.bottom, valuePostion)
    }


    protected open fun getVPDataAxisStdY(dataAxis:DataLineAxis): Float {
        return if (dataAxis.isAxisStdStatus) {
            getVPValPosition(dataAxis.dataAxisStd,dataAxis)
        } else {
            bodyViewport.bottom
        }
    }


    protected open fun getLnXValPosition(xValue: Float, maxValue: Float, minValue: Float): Float {
        // 对应的X坐标
        val maxminRange =  Math.sub(maxValue, minValue)
        val xScale =  Math.div( Math.sub(xValue, minValue), maxminRange)
        val XvaluePos: Float =  Math.mul(getPlotScreenWidth(), xScale)
        return  Math.add(bodyViewport.left, XvaluePos)
    }


    /**
     * 竖向柱形图
     * Y轴的屏幕高度/数据轴的刻度标记总数 = 步长
     * @return Y轴步长
     */
    protected open fun getVerticalYSteps(tickCount: Int): Float {
        return  Math.div(getPlotScreenHeight(), tickCount.toFloat())
    }

    /**
     * 竖向柱形图
     * 得到X轴的步长
     * X轴的屏幕宽度 / 刻度标记总数  = 步长
     * @param num 刻度标记总数
     * @return X轴步长
     */
    protected open fun getVerticalXSteps(tickCount: Int): Float {
        //柱形图为了让柱形显示在tick的中间，会多出一个步长即(dataSet.size()+1)	
        return  Math.div(getPlotScreenWidth(), tickCount.toFloat())
    }


    protected open fun getAxisXPos(location: ChartEnum.AxisLocation): Float {
        if (ChartEnum.AxisLocation.RIGHT == location) {    //显示在右边
            return bodyViewport.right
        } else if (ChartEnum.AxisLocation.LEFT == location) {
            //显示在左边
            return bodyViewport.left
        } else if (ChartEnum.AxisLocation.VERTICAL_CENTER == location) {
            //显示在中间
            return bodyViewport.centerX
        }
        return 0f
    }

    protected open fun getAxisYPos(location: ChartEnum.AxisLocation): Float {
        if (ChartEnum.AxisLocation.TOP == location) {
            return bodyViewport.top
        } else if (ChartEnum.AxisLocation.BOTTOM == location) {
            return bodyViewport.bottom
        } else if (ChartEnum.AxisLocation.HORIZONTAL_CENTER == location) {
            return bodyViewport.centerY
        }
        return 0f
    }


    //////////////////////////////////////////////////////////////////////////
    //横轴




    /**
     * 返回标签显示格式
     *
     * @param value 传入当前值
     * @return 显示格式
     */
    protected  fun getFormatterItemLabel(value: Double): String {
        val itemLabel: String = try {
            itemLabelFormatter?.invoke(value)?:value.toString()
        } catch (ex: Exception) {
            value.toString()
        }
        return itemLabel
    }

    fun getFormatterItemLabel(value: Float): String = getFormatterItemLabel(value.toDouble())

    /**
     * 检查Y轴的刻度是否显示
     * @param currentY    y坐标
     * @param moveY    y坐标平移值
     * @return    是否绘制
     */
    /*protected open fun isDrawYAxisTickMarks(currentY: Float, moveY: Float): Boolean {
        return !(currentY.compareTo(plotArea.top - moveY) == -1 || currentY.compareTo(plotArea.bottom - moveY) == 1)
    }*/


    /**
     * 检查X轴的刻度是否显示
     * @param currentX    x坐标
     * @param moveX    x坐标平移值
     * @return 是否绘制
     */
    /*protected open fun isDrawXAxisTickMarks(currentX: Float, moveX: Float): Boolean {
        if ((currentX + moveX).compareTo(plotArea.left) == -1) return false
        return (currentX + moveX).compareTo(plotArea.right) != 1
    }*/


    protected abstract fun drawClipCategoryAxisGridlines(
        canvas: Canvas,
        categoryAxis: CategoryLineAxis=this.categoryAxis,
        pos: ChartEnum.AxisLocation=this.categoryAxis.axisLocation
    )

    protected abstract fun drawClipDataAxisGridlines(
        canvas: Canvas,
        dataAxis: DataLineAxis=this.dataAxis,
        pos: ChartEnum.AxisLocation=this.dataAxis.axisLocation
    )

    abstract fun drawClipPlot(
        canvas: Canvas,
        dataAxis: DataLineAxis=this.dataAxis,
        categoryAxis: CategoryLineAxis=this.categoryAxis
    )


     private fun drawClipAxisClosed(canvas: Canvas) {
        if (!isAxesClosed) return
        dataAxis.renderClipAxisClosed(canvas,bodyViewport)
        categoryAxis.renderClipAxisClosed(canvas,bodyViewport)
    }

    protected open fun drawClipAxisLine(canvas: Canvas) {
        dataAxis.renderClipAxisLine(canvas,bodyViewport)
        categoryAxis.renderClipAxisLine(canvas,bodyViewport)
    }

    protected  fun drawClipDataAxisTickMarks(canvas: Canvas) {
        dataAxis.renderAxisLabels(canvas, bodyViewport, lstDataTick, left, moveX, moveY)
    }

    protected  fun drawClipCategoryAxisTickMarks(canvas: Canvas) {
        categoryAxis.renderAxisLabels(canvas, bodyViewport, lstCateTick, left, moveX, moveY)
    }

    protected abstract fun drawClipLegend(canvas: Canvas)

    protected open fun drawFixedPlot(canvas: Canvas): Boolean {
        /*moveY = 0.0f
        moveX = 0f*/

        //绘制Y轴tick和marks	
        drawClipDataAxisGridlines(canvas)

        //绘制X轴tick和marks	
        drawClipCategoryAxisGridlines(canvas)

        //绘图
        drawClipPlot(canvas)

        //轴 线
        drawClipAxisClosed(canvas)
        drawClipAxisLine(canvas)

        //轴刻度
        drawClipDataAxisTickMarks(canvas)
        drawClipCategoryAxisTickMarks(canvas)

        //图例
        drawClipLegend(canvas)
        return true
    }


   /* protected  fun getClipYMargin(): Float {
        return myMargin + this.borderWidth
    }

    protected  fun getClipXMargin(): Float {
        return mxMargin + this.borderWidth
    }*/


    protected  fun drawClipVerticalPlot(canvas: Canvas, plotGrid: PlotGrid): Boolean {
        //显示绘图区rect
        val offsetX = translateXY[0]
        val offsetY = translateXY[1]
        //initMoveXY()
        val yMargin = this.borderWidth
        val xMargin = this.borderWidth
        var gWidth = 0.0f

        drawClipAxisClosed(canvas)

        //设置图显示范围
        canvas.withSave {
            canvas.clipRect(left, top, right, bottom)
            if (PanMode.VERTICAL == plotPanMode || PanMode.FREE == plotPanMode) {
                if (plotGrid.isShowVerticalLines)
                    gWidth = plotGrid.gridLineVerticalPaint.strokeWidth
                //绘制Y轴tick和marks
                canvas.withSave {
                    canvas.clipRect(bodyViewport.left - gWidth, bodyViewport.top - gWidth, bodyViewport.right + gWidth, bodyViewport.bottom + gWidth)
                    canvas.translate(0f, offsetY)
                    drawClipDataAxisGridlines(canvas)
                }

            } else {
                drawClipDataAxisGridlines(canvas)
            }
            if (PanMode.HORIZONTAL == plotPanMode || PanMode.FREE == plotPanMode) {
                if (plotGrid.isShowHorizontalLines)
                    gWidth = plotGrid.gridLineHorizontalPaint.strokeWidth
                //绘制X轴tick和marks
                canvas.withSave {
                    canvas.clipRect(
                        bodyViewport.left - gWidth, bodyViewport.top - gWidth,
                        bodyViewport.right + gWidth, bodyViewport.bottom + gWidth
                    )
                    canvas.translate(offsetX, 0f)
                    drawClipCategoryAxisGridlines(canvas)
                }
            } else {
                drawClipCategoryAxisGridlines(canvas)
            }

            //设置绘图区显示范围
            /*canvas.save()
            clipExt.calc(getType())
            canvas.clipRect(
                bodyViewport.left - clipExt.clipExtLeft,
                bodyViewport.top - clipExt.clipExtTop,
                bodyViewport.right + clipExt.clipExtRight,
                bodyViewport.bottom + clipExt.clipExtBottom
            )*/

            //canvas.clipRect(plotArea.left+ 0.5f , plotArea.top + 0.5f,
            //		 plotArea.right + 0.5f, plotArea.bottom + 0.5f );

            //canvas.restore()

            canvas.withSave {
                canvas.translate(moveX, moveY)
                //绘图
                drawClipPlot(canvas)
            }
        }

        //轴 线		
        drawClipAxisLine(canvas)
        /////////////////////////////////////////

        //轴刻度
        if (PanMode.VERTICAL == plotPanMode || PanMode.FREE == plotPanMode) {
            //绘制Y轴tick和marks
            canvas.withSave {
                canvas.clipRect(left, top + yMargin, right, bottom - yMargin)
                canvas.translate(0f, offsetY)
                drawClipDataAxisTickMarks(canvas)
            }

        } else {
            drawClipDataAxisTickMarks(canvas)
        }
        if (PanMode.HORIZONTAL == plotPanMode || PanMode.FREE == plotPanMode) {
            //绘制X轴tick和marks
            canvas.withSave {
                canvas.clipRect(left + xMargin, top, right - xMargin, bottom) //mRight + xMargin
                canvas.translate(offsetX, 0f)
                drawClipCategoryAxisTickMarks(canvas)
            }

        } else {
            drawClipCategoryAxisTickMarks(canvas)
        }

        /////////////////////////////////////////

        //图例
        drawClipLegend(canvas)
        return true
    }

    /////////////////////////  
    protected  fun drawClipHorizontalPlot(canvas: Canvas, plotGrid: PlotGrid): Boolean {
        //显示绘图区rect
        val offsetX = translateXY[0]
        val offsetY = translateXY[1]
        //initMoveXY()
        val yMargin = this.borderWidth
        val xMargin = this.borderWidth
        var gWidth = 0.0f

        drawClipAxisClosed(canvas)

        //设置图显示范围
        canvas.withSave {
            canvas.clipRect(left, top, right, bottom)
            if (PanMode.VERTICAL == plotPanMode || PanMode.FREE == plotPanMode) {
                if (plotGrid.isShowVerticalLines)
                    gWidth = plotGrid.gridLineVerticalPaint.strokeWidth
                //绘制Y轴tick和marks
                canvas.withSave {
                    canvas.clipRect(
                        bodyViewport.left - gWidth, bodyViewport.top - gWidth,
                        bodyViewport.right + gWidth, bodyViewport.bottom + gWidth
                    )
                    canvas.translate(0f, offsetY)
                    drawClipCategoryAxisGridlines(canvas)
                }

            } else {
                drawClipCategoryAxisGridlines(canvas)
            }
            if (PanMode.HORIZONTAL == plotPanMode || PanMode.FREE == plotPanMode) {
                if (plotGrid.isShowHorizontalLines)
                    gWidth = plotGrid.gridLineHorizontalPaint.strokeWidth

                //绘制X轴tick和marks
                canvas.withSave {
                    canvas.clipRect(
                        bodyViewport.left - gWidth, bodyViewport.top - gWidth,
                        bodyViewport.right + gWidth, bodyViewport.bottom + gWidth
                    )
                    canvas.translate(offsetX, 0f)
                    drawClipDataAxisGridlines(canvas)
                }
            } else {
                drawClipDataAxisGridlines(canvas)
            }
            //////////////////////////////////////////////////

            //////////////////////////////////////////////////
            //设置绘图区显示范围
            /*canvas.save()
            clipExt.calc(getType())
            canvas.clipRect(
                bodyViewport.left - clipExt.clipExtLeft,
                bodyViewport.top - clipExt.clipExtTop,
                bodyViewport.right + clipExt.clipExtRight,
                bodyViewport.bottom + clipExt.clipExtBottom
            )*/

            //canvas.clipRect(plotArea.left , plotArea.top ,
            //				mRight, plotArea.bottom);
            canvas.withSave {
                canvas.translate(moveX, moveY)
                //绘图
                drawClipPlot(canvas)
            }
        }

        //////////////////////////////////////////////////			
        //轴线		
        drawClipAxisLine(canvas)
        if (PanMode.HORIZONTAL == plotPanMode || PanMode.FREE == plotPanMode) {
            //绘制X轴tick和marks
            canvas.withSave {
                //放开，排除掉border的宽度
                canvas.clipRect(left + xMargin, top, right - xMargin, bottom)
                canvas.translate(offsetX, 0f)
                drawClipDataAxisTickMarks(canvas)
            }
        } else {
            drawClipDataAxisTickMarks(canvas)
        }
        if (PanMode.VERTICAL == plotPanMode || PanMode.FREE == plotPanMode) {
            //绘制Y轴tick和marks
            canvas.withSave {
                canvas.clipRect(
                    left, top + yMargin,
                    right, bottom - yMargin
                )
                canvas.translate(0f, offsetY)
                drawClipCategoryAxisTickMarks(canvas)
            }
        } else {
            drawClipCategoryAxisTickMarks(canvas)
        }
        //////////////////////////////////////////////////

        //图例
        drawClipLegend(canvas)
        return true
    }
    /////////////////////////

    /////////////////////////

    override fun renderBody(canvas: Canvas): Boolean {

        super.renderBody(canvas)
        var ret = true

        //计算主图表区范围
        calcPlotRange()
        //画Plot Area背景
        bodyViewport.render(canvas)

        //绘制图表
        ret = if (isScrollEnabled) {
            when (gridDirection) {
                GridDirection.HORIZONTAL -> drawClipHorizontalPlot(canvas, plotGrid)
                GridDirection.VERTICAL -> drawClipVerticalPlot(canvas, plotGrid)
            }
        } else {
            drawFixedPlot(canvas)
        }
        return ret
    }

    override fun readerForeground(canvas: Canvas) {
        super.readerForeground(canvas)

        //绘制轴标题
        axisTitle?.render(canvas, innerRect)
    }

    open fun drawFocusRect(canvas: Canvas, i: Int, j: Int, barLeft: Float, barTop: Float, barRight: Float, barBottom: Float) {
        selectHelper.drawFocusRect(canvas, i, j, barLeft, barTop, barRight, barBottom)
    }

    //open fun saveBarRectFRecord(i: Int, j: Int, fl: Float, fl1: Float, fl2: Float, fl3: Float) {
        //selectHelper?.saveBarRectFRecord(i, j, fl, fl1, fl2, fl3)
    //}

    //open fun savePointRecord(dataID: Int, i: Int, fl: Float, fl1: Float, fl2: Float, fl3: Float, fl4: Float, fl5: Float) {
        //selectHelper?.savePointRecord(dataID, i, fl, fl1, fl2, fl3, fl4, fl5)
    //}

}


/*class ClipExt {
    //用于扩展clip绘图区范围	
    *//**
     * 指定绘图区clip时向左扩展范围
     *//*
    var mClipExtLeft = -1f

    *//**
     * 指定绘图区clip时向上扩展范围
     *//*
    var mClipExtTop = -1f

    *//**
     * 指定绘图区clip时向右扩展范围
     *//*
    var mClipExtRight = -1f

    *//**
     * 指定绘图区clip时向下扩展范围
     *//*
    var mClipExtBottom = -1f

    *//**
     * 返回绘图区clip时实际向左扩展范围
     *//*
    var clipExtLeft = 0.5f

    *//**
     * 返回绘图区clip时实际向上扩展范围
     *//*
    var clipExtTop = 0.5f

    *//**
     * 返回绘图区clip时实际向右扩展范围
     *//*
    var clipExtRight = 0.5f

    *//**
     * 返回绘图区clip时实际向下扩展范围
     *//*
    var clipExtBottom = 0.5f

    *//**
     * 用于计算实际扩展值
     * @param type 图类型
     *//*
    fun calc(type: ChartEnum.ChartType) {
        when (type) {
            ChartEnum.ChartType.LINE, ChartEnum.ChartType.SPLINE, ChartEnum.ChartType.AREA -> {
                clipExtLeft = if (mClipExtLeft.compareTo(-1f) == 0) {
                    10f
                } else {
                    mClipExtLeft
                }
                clipExtTop = if (mClipExtTop.compareTo(-1f) == 0) {
                    0.5f
                } else {
                    mClipExtTop
                }
                clipExtRight = if (mClipExtRight.compareTo(-1f) == 0) {
                    10f
                } else {
                    mClipExtRight
                }
                clipExtBottom = if (mClipExtBottom.compareTo(-1f) == 0) {
                    10f
                } else {
                    mClipExtBottom
                }
            }

            else -> {}
        }
    }
}*/

